package com.jiegui.payinterface.bean;

import com.jiegui.payinterface.enums.PaymentStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * 付款结果
 *
 * @author wuqicheng
 * @date 2021/3/10
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PaymentRes extends HashMap<String, String> {

    /** 付款单编码 */
    private String billCode;

    /** 交易状态  */
    private PaymentStatus status;

    /** 响应编号  */
    private String responseCode;

    /** 响应消息  */
    private String responseMessage;

    public Map<String, String> toMap() {
        Map<String, String> result = new HashMap<>();
        for (Entry<String, String> entry : entrySet()) {
            result.put(entry.getKey(), entry.getValue());
        }
        result.put("billCode", billCode);
        result.put("status", status != null ? status.toString() : null);
        result.put("responseCode", responseCode);
        result.put("responseMessage", responseMessage);
        return result;
    }

    public SortedMap<String, String> toSortMap() {
        SortedMap<String, String> result = new TreeMap<>();
        for (Entry<String, String> entry : entrySet()) {
            result.put(entry.getKey(), entry.getValue());
        }
        return result;
    }


}
